{% extends "logged_base.html" %}
{% load tagging_tags%}

{% block _style %}
	<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}_styles/smart.css" media="all" />
{% endblock %}

{% block _script %}
	<script type="text/javascript" src="{{ MEDIA_URL }}_scripts/sprint/chrono.js"></script>
	<script type="text/javascript" src="{{ MEDIA_URL }}_scripts/sprint/smart-input.js"></script>
	<script type="text/javascript" src="{{ MEDIA_URL }}_scripts/sprint/sprint-status.js"></script>
	<script type="text/javascript" src="{{ MEDIA_URL }}_scripts/sprint/planning2/create-task.js"></script>
	
{% endblock %}

{% block body %}

	<div id="planning-status">
		<form id="planning-status-form" method="post" action="{% url planning2_status id_sprint %}">
			{% include "planning-status.html" with time=sprint.planning2_time %}
		</form>
	</div>

	{% include "messages.html" %}

	<h1>{{ _('Planning') }} 2</h1>

	<div id="hidden-task" class="hidden">
		{% include "smart-input.html" %}
	</div>
		
	<!-- Historias dentro do sprint -->
	<form id="edit-formset-histories" method="post" action="{% url edit_sprint id_sprint %}" >
		{% csrf_token %}
		{{ histories_formset.management_form }}

		<table id="sprint-histories" class="task-board">
			<thead>
				<tr class="title" >
					<td colspan="4"><h2>{{_('Sprint histories')}}</h2></td>
				</tr>
				<tr>
					<td></td>
					<td>
						<input id="select-all-none" type=CHECKBOX name="select" />
					</td>
					<td colspan="" style="text-align:left;">
						<button type="submit" name="delete-task" title="{{_('Delete from dashboard')}}">{{_('Delete')}}</button>
					</td>
					<td><h3>{{_('Estimate')}}</h3></td>
				</tr>
			</thead>
		
			<tbody>
				{% for history in histories_formset.forms  %}
				<tr>
					<td><!-- Keyboard shortcuts--></td>
					<td class="history-selection">
						{{history.check}}
					</td>
					<td class="edit-history">
						{% tags_for_object history.instance as tag_list %} 
						{% for tag in tag_list %}
							<span class="tags"><i>{{tag}}</i></span>
						{% endfor %}
						{{history.instance.name}} 
						{% if history.instance.description %}
							<i>{{history.instance.description}}</i>
						{% endif %}
						
						<!-- Edit History Modal -->	
						<div class="transparent-box modal-background" style="display:none">
							<div id="create-project-modal" class="modal">
								<h2>{{_('Edit History')}}</h2>	
								<fieldset>
									{{history.id}}
									<div class="grid-12-12">
										<label id='label_name' class="form-lbl" for="">
											{{history.name.label}}
										</label>
										{{history.name}}
									</div>
									<div class="grid-12-12">
										<label id='label_name' class="form-lbl" for="">
											{{history.description.label}}
										</label>
										{{history.description}}
									</div>
									<div class="grid-12-12">
										<label id='label_name' class="form-lbl" for="">
											{{history.tags.label}}
										</label>
										{{history.tags}}
									</div>
									<div class="grid-12-12">
										<label id='label_name' class="form-lbl" for="">
											{{history.estimate.label}}
										</label>
										{{history.estimate}}
									</div>
								</fieldset>
								<button type="submit">{{_('Adicionar')}}</button>
								<button class="cancel-edit-history" >{{_('Cancel')}}</button>
							</div>
						</div>
						
						<br/>
						<!-- Tasks -->
						<table id="sprint-tasks" class="task-board">
							<thead>
								<a href="#add-task"> + {{_('Task')}}</a>
							</thead>
							
							<tbody>
								{% for task in history.task_formset %}
								<tr>
									<td>
										<input id="select-all-none" type=CHECKBOX name="select" />
									</td>
									<td colspan="" style="text-align:left;">
										{{task.instance.name}}								
									</td>
								</tr>
								{% endfor %}
							</tbody>
						</table>						
						
					</td>
					<td>
						{% if history.instance.estimate %}
							{{history.instance.estimate}}
						{% else %}
							0
						{% endif %}
					</td>
				</tr>
			{% endfor %}
			</tbody>
		</table>
	</form>
	
{% endblock %}

